Skip to content

feat: add SameNetTraceCombiningSolver to merge close same-net collinear trace segments#271

Closed
chengyixu wants to merge 2 commits intotscircuit:mainfrom
chengyixu:feat/same-net-trace-combining
Closed

feat: add SameNetTraceCombiningSolver to merge close same-net collinear trace segments#271
chengyixu wants to merge 2 commits intotscircuit:mainfrom
chengyixu:feat/same-net-trace-combining

Conversation

@chengyixu
Copy link
Copy Markdown

@chengyixu chengyixu commented May 4, 2026

Summary

This PR implements the SameNetTraceCombiningSolver which merges same-net trace segments that are close together and collinear (same X or same Y axis-aligned).

How it works

  • Groups schematic traces by globalConnNetId
  • Extracts axis-aligned segments (horizontal or vertical)
  • Finds pairs that are collinear (within 0.05 tolerance) and have a gap ≤ 0.15 units
  • Merges the pair by extending one segment to span the full combined range and removing the other

The solver is inserted in the pipeline after traceCleanupSolver, before netLabelPlacementSolver.

Tests

All 59 tests pass. Snapshots updated to reflect the visual improvement.

/claim #34
/claim #29

chengyixu added 2 commits May 4, 2026 21:50
…ar trace segments

/claim tscircuit#29

Implements a new pipeline phase that reduces visual clutter by merging
collinear trace segments belonging to the same net when they are close
together (gap <= 0.15 units) or overlapping.

The solver:
1. Groups traces by globalConnNetId
2. Extracts axis-aligned segments from each trace path
3. Finds mergeable pairs (collinear within 0.05 tolerance, gap <= 0.15)
4. Extends one segment to cover the full span, collapses the other

Pipeline integration:
- Runs after TraceCleanupSolver, before final NetLabelPlacementSolver
- Single-step synchronous solver (no iterative state machine needed)

Tests:
- 8 new unit tests covering merge, no-merge, empty, vertical, overlap cases
- All 57 existing tests pass (9 visual snapshots updated to reflect improvement)
- TypeScript type check clean (bunx tsc --noEmit)
@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
schematic-trace-solver Ready Ready Preview, Comment May 4, 2026 1:53pm

Request Review

@chengyixu
Copy link
Copy Markdown
Author

Hi @seveibar! This PR implements the SameNetTraceCombiningSolver for issue #34 — it merges same-net trace segments that are close together and collinear (same X or same Y).

How it works:

  • Groups schematic traces by globalConnNetId
  • Extracts axis-aligned segments (horizontal or vertical)
  • Finds pairs that are collinear (within 0.05 tolerance) and have a gap ≤ 0.15 units
  • Merges by extending one segment to cover the full span and removing the other

All CI checks pass (test, type-check, format-check, Vercel preview). Snapshots updated to reflect the visual improvement. Would appreciate a review when you get a chance — happy to make any adjustments!

@chengyixu
Copy link
Copy Markdown
Author

This PR also resolves issue #29 (New Phase To combine same-net trace segments that are close together) — same solution applies to both issues.

/claim #29

@chengyixu
Copy link
Copy Markdown
Author

Hey @seveibar, this PR (#271) implements SameNetTraceCombiningSolver for issue #34. All CI is green (test, type-check, format-check). Ready for review when you have a moment. Thanks!

@chengyixu
Copy link
Copy Markdown
Author

Closing in favor of #276 which has the updated implementation with all CI passing.

@chengyixu chengyixu closed this May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant